﻿using AttributeRouting.Web.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Water.Model;

namespace Water.RestService.Controllers
{
    public class DropDownListController : ApiController
    {
        private DropdownList ddl;

        [GET("GetAllDropdownlists")]
        public IList<DropdownList> GetAllDropDownLists()
        {
            ddl = new DropdownList();
            return ddl.GetAllDropDownLists();
        }

        [GET("GetDropdownlists/{selp}")]
        public IList<DropdownList> GetDropdownlists(string selp)
        {
            ddl = new DropdownList();
            return ddl.GetDropdownList(selp);
        }

        [POST("AddDropdownlist")]
        public bool PostAddDropdownlist(DropdownList pddl)
        {
            ddl = new DropdownList();
            bool result = ddl.AddDropDownList(pddl) > 0 ? true : false;
            return result;
        }


        [POST("EditDropdownList")]
        public bool PostDropdownList(DropdownList pddl)
        {
            ddl = new DropdownList();
            bool result = ddl.UpdateDropDownList(pddl) > 0 ? true : false;
            return result;
        }

        [GET("DeleteDropdownList/{sid}")]
        public bool GetDeleteDropdownList(int sid)
        {
            ddl = new DropdownList();
            bool result = ddl.DelDropDownList(sid) > 0 ? true : false;
            return result;
        }
    }
}
